package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Exguide;
import com.ruoyi.system.service.IExguideService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 展览导览Controller
 * 
 * @author ruoyi
 * @date 2024-01-18
 */
@Controller
@RequestMapping("/system/exguide")
public class ExguideController extends BaseController
{
    private String prefix = "system/exguide";

    @Autowired
    private IExguideService exguideService;

    @RequiresPermissions("system:exguide:view")
    @GetMapping()
    public String exguide()
    {
        return prefix + "/exguide";
    }

    /**
     * 查询展览导览列表
     */
    @RequiresPermissions("system:exguide:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Exguide exguide)
    {
        startPage();
        List<Exguide> list = exguideService.selectExguideList(exguide);
        return getDataTable(list);
    }

    /**
     * 导出展览导览列表
     */
    @RequiresPermissions("system:exguide:export")
    @Log(title = "展览导览", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Exguide exguide)
    {
        List<Exguide> list = exguideService.selectExguideList(exguide);
        ExcelUtil<Exguide> util = new ExcelUtil<Exguide>(Exguide.class);
        return util.exportExcel(list, "展览导览数据");
    }

    /**
     * 新增展览导览
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存展览导览
     */
    @RequiresPermissions("system:exguide:add")
    @Log(title = "展览导览", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Exguide exguide)
    {
        return toAjax(exguideService.insertExguide(exguide));
    }

    /**
     * 修改展览导览
     */
    @RequiresPermissions("system:exguide:edit")
    @GetMapping("/edit/{exguideId}")
    public String edit(@PathVariable("exguideId") Long exguideId, ModelMap mmap)
    {
        Exguide exguide = exguideService.selectExguideByExguideId(exguideId);
        mmap.put("exguide", exguide);
        return prefix + "/edit";
    }

    /**
     * 修改保存展览导览
     */
    @RequiresPermissions("system:exguide:edit")
    @Log(title = "展览导览", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Exguide exguide)
    {
        return toAjax(exguideService.updateExguide(exguide));
    }

    /**
     * 删除展览导览
     */
    @RequiresPermissions("system:exguide:remove")
    @Log(title = "展览导览", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(exguideService.deleteExguideByExguideIds(ids));
    }
}
